﻿<!DOCTYPE html>
<!--设备设施列表-->
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="/static/js/common.js"></script>

</head>
<body>
    
<div id="app" v-cloak>   
        <el-row>
            <el-col :span="4">
                <el-tree :data="TreeData" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
            </el-col>
            <el-col :span="20">
                <el-form ref="form" :inline="true" label-position="right" label-width="100px" :model="formInline" class="demo-form-inline" style="margin-bottom: 15px;">
                    <el-row>
                        <el-col class="head-tool">
                            <el-button type="primary" @click="onSubmit">{{col.btnSelect}}</el-button>
                            <el-button type="primary" @click="onSubmitForm">{{col.btnConfirm}}</el-button>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :xs="6" :sm="6" :md="6" :lg="4" :xl="4">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.Device" :placeholder="EquipmenFacilities.Device" size="mini">
                                        <template slot="prepend">
                                            {{EquipmenFacilities.Device+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="6" :sm="6" :md="6" :lg="4" :xl="4">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.FunctionalPart" :placeholder="EquipmenFacilities.FunctionalPart" size="mini">
                                        <template slot="prepend">
                                            {{EquipmenFacilities.FunctionalPart+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="6" :sm="6" :md="6" :lg="4" :xl="4">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.Sub_functionPart" :placeholder="EquipmenFacilities.Sub_functionPart" size="mini">
                                        <template slot="prepend">
                                            {{EquipmenFacilities.Sub_functionPart+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="6" :sm="6" :md="6" :lg="4" :xl="4">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.B_ComponentName" :placeholder="EquipmenFacilities.B_ComponentName" size="mini">
                                        <template slot="prepend">
                                            {{EquipmenFacilities.B_ComponentName+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="6" :sm="6" :md="6" :lg="4" :xl="4">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.Malfunction" :placeholder="EquipmenFacilities.Malfunction" size="mini">
                                        <template slot="prepend">
                                            {{EquipmenFacilities.Malfunction+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="6" :sm="6" :md="6" :lg="4" :xl="4">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.Risk" :placeholder="EquipmenFacilities.Risk" size="mini">
                                        <template slot="prepend">
                                            {{EquipmenFacilities.Risk+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="6" :sm="6" :md="6" :lg="4" :xl="4">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.ExpectedFunction" :placeholder="EquipmenFacilities.ExpectedFunction" size="mini">
                                        <template slot="prepend">
                                            {{EquipmenFacilities.ExpectedFunction+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="6" :sm="6" :md="6" :lg="4" :xl="4">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.HazardousFactors" :placeholder="EquipmenFacilities.HazardousFactors" size="mini">
                                        <template slot="prepend">
                                            {{EquipmenFacilities.HazardousFactors+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="6" :sm="6" :md="6" :lg="4" :xl="4">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.ControlRequirement" :placeholder="EquipmenFacilities.ControlRequirement" size="mini">
                                        <template slot="prepend">
                                            {{EquipmenFacilities.ControlRequirement+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="6" :sm="6" :md="6" :lg="4" :xl="4">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input size="mini">
                                        <template slot="prepend">
                                            {{EquipmenFacilities.RiskLevel+mark.m}}
                                        </template>
                                        <el-select @visible-change="visibleChange" v-model="formInline.model.RiskLevel" slot="suffix" :placeholder="EquipmenFacilities.RiskLevel">
                                            <el-option label="请选择" value=""></el-option>
                                            <el-option v-for="item in RiskLevel" :label="item.value" :value="item.key"></el-option>
                                        </el-select>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                    </el-row>
                </el-form>
                <el-table ref="table" :data="ListItem.tableData"
                          :height="ListItem.tableHeight"
                          border @selection-change="handleSelectionChange" row-style="height:10px"
                          style="width: 100%" :row-key="mygetRowKeys">
                    <el-table-column type="selection" align="center" width="55">
                    </el-table-column>

                    <el-table-column prop="Device"
                                     :label="EquipmenFacilities.Device" show-overflow-tooltip="true" width="100">
                    </el-table-column>
                    <el-table-column prop="FunctionalPart"
                                     :label="EquipmenFacilities.FunctionalPart"  show-overflow-tooltip="true" width="100">
                    </el-table-column>
                    <el-table-column prop="Sub_functionPart"
                                     :label="EquipmenFacilities.Sub_functionPart"  show-overflow-tooltip="true" width="100">
                    </el-table-column>
                    <el-table-column prop="B_ComponentName"
                                     :label="EquipmenFacilities.B_ComponentName" show-overflow-tooltip="true" width="100">
                    </el-table-column>
                    <el-table-column prop="ExpectedFunction"
                                     :label="EquipmenFacilities.ExpectedFunction"  show-overflow-tooltip="true" width="100">
                    </el-table-column>
                    <el-table-column prop="Malfunction"
                                     :label="EquipmenFacilities.Malfunction" show-overflow-tooltip="true" width="100">
                    </el-table-column>
                    <el-table-column prop="Risk"
                                     :label="EquipmenFacilities.Risk">
                    </el-table-column>
                    <el-table-column prop="HazardousFactors"
                                     :label="EquipmenFacilities.HazardousFactors" show-overflow-tooltip="true" width="100">
                    </el-table-column>
                    <el-table-column prop="ControlRequirement"
                                     :label="EquipmenFacilities.ControlRequirement" show-overflow-tooltip="true" width="100">
                    </el-table-column>
                    <el-table-column prop="RiskLevel"
                                     :label="EquipmenFacilities.RiskLevel">
                    </el-table-column>
             
                </el-table>
                <el-row type="flex" justify="end">
                    <el-pagination ref="page" @size-change="handleSizeChange"
                                   @current-change="handleCurrentChange"
                                   :current-page="ListItem.currentPage"
                                   :page-sizes="ListItem.pagesizes"
                                   :page-size="ListItem.pagesize"
                                   :layout="ListItem.layout"
                                   :total="ListItem.total">
                    </el-pagination>

                </el-row>
            </el-col>
        </el-row>
    </div>
    <script type="text/javascript">
        app = new Vue({
            el: '#app',
            data: function () {
                return {
                    TreeData: [],
                    id:"",
                    mydata: RiskControlInformation,
                    defaultProps: {
                        children: 'children',
                        label: 'label'
                    },
                    RiskLevel: [],
                    ListItem: ListItem,
                    formInline: {
                        model: {
                            Device: '',
                            FunctionalPart: '',
                            Sub_functionPart: '',
                            B_ComponentName: '',
                            ExpectedFunction: '',
                            Malfunction: '',
                            Risk: '',
                            HazardousFactors: '',
                            ControlRequirement: '',
                            RiskLevel: ''
                        },
                        offset: 0,
                        limit: 10
                    }
                }
            },created: function () {
                var currApp = this;
                window.onresize = function () {
                    currApp.ListItem.tableHeight = window.innerHeight -
                        currApp.$refs.table.$el.offsetTop - 60;
                    if (currApp.ListItem.tableHeight < 112) {
                        currApp.ListItem.tableHeight = 112;
                    }
                }
            },
            mounted: function () {
                this.id = getUrlParam("id");
                //获取下拉菜单内容
                this.RiskLevel = getDicData('03');
                //初始化数据
                this.GetPageData(1);
                //列表高度自适应
                tablehigh(this);
                this.toggleSelection();
                this.TreeData = fn(this.mydata, "0");
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                mygetRowKeys: function (row) {
                    return row.Risk;
                },
                toggleSelection: function () {
                    var mythis = this;
                    mythis.$nextTick(function () {
                     //   var rows = parent.app.Form.OperationRelatedActivitiesRish;

                        var rows = [];
                        $.extend(true, rows, parent.app.Form.OperationRelatedActivitiesRish);


                        var array = [];
                        for (var i = 0; i < rows.List.length; i++) {
                            var obj = {};
                            obj.Risk = rows[i];
                            array.push(obj);
                        }
                        if (array) {
                            array.forEach(function (arr) {
                                mythis.$refs.table.toggleRowSelection(arr, true);
                            });
                        } else {
                            mythis.$refs.table.clearSelection();
                        }

                    })
                },
                handleNodeClick: function (data) {
                    console.log(data);
                },
                closeDialog: function () { closeDialog(this); },
                //获取分页数据
                GetPageData: function (currentIndex) { GetPageData(this, currentIndex, '/api/EquipmenFacilities/GetList') },
                //pagesize改变 触发方法
                handleSizeChange: function (val) { handleSizeChange(this, val); },
                handleSelectionChange: function (val) { handleSelectionChange(this, val); },
                //跳页触发方法
                handleCurrentChange: function (val) { handleCurrentChange(this, val); },
                onSubmitForm: function () {
                    
                    //var aaa = {};
                    //$.extend(true, aaa, parent.app.Form.OperationRelatedActivitiesRish)

                      for (var i = 0; i < parent.app.Form.OperationRelatedActivitiesRish.length; i++) {
                          if (this.id == parent.app.Form.OperationRelatedActivitiesRish[i].RiskStepsId) {
                      
                              parent.app.Form.OperationRelatedActivitiesRish[i].List.length = 0;
                              for (var j = 0; j < this.ListItem.tableMultipleSelection.length; j++) {
                                  parent.app.Form.OperationRelatedActivitiesRish[i].List.push({
                                    id: this.ListItem.tableMultipleSelection[j].id,
                                    Pid: this.id,
                                    Risk: this.ListItem.tableMultipleSelection[j].Risk,
                                    ControlRequirement: this.ListItem.tableMultipleSelection[j].ControlRequirement,
                                    HazardousFactors: this.ListItem.tableMultipleSelection[j].HazardousFactors,
                                });
                              }
                              break;
                        }
                    }
                    //$.extend(true, parent.app.Form.OperationRelatedActivitiesRish, aaa)
                    parent.app.ListItem.dialogVisible = false;
                }
            }
        });

    </script>
</body>

</html>
